package com.gewu.bookeeping.MyDb.dao;

import android.content.Context;

import com.gewu.bookeeping.IModel.IMenyInDaoModel;
import com.gewu.bookeeping.MyDb.MyDatabase;
import com.gewu.bookeeping.MyDb.bean.MesBeanIn;
import com.gewu.bookeeping.MyDb.bean.MesBeanOut;
import com.j256.ormlite.dao.Dao;

import java.sql.SQLException;
import java.util.List;

public class MesOutPerson implements IMenyInDaoModel {

    private Dao<MesBeanOut,Integer> mesBeanOuts;

    public MesOutPerson(Context context) {
        try {
            this.mesBeanOuts = MyDatabase.getInstance(context).getDao(MesBeanOut.class);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


    @Override
    public int add(Object m) {
        int i = 0;
        try {
            i = mesBeanOuts.create((MesBeanOut) m);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }

    @Override
    public int delect(int id) {
        return 0;
    }

    @Override
    public List<MesBeanOut> quer() {
        List<MesBeanOut> aliBeanIn = null;
        try {
            aliBeanIn = mesBeanOuts.queryForAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return aliBeanIn;
    }

    @Override
    public List<MesBeanOut> querLike(String values) {
        List<MesBeanOut> time=null;
        try {
            time = mesBeanOuts.queryForEq("time", values);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return time;
    }
}
